package servlet.admin.message;

import entity.Message;
import service.MessageService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet(name = "AdminMessageDetailServlet")
public class AdminMessageDetailServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request, response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        MessageService service=new MessageService();
        Integer messageId=Integer.parseInt(request.getParameter("messageId"));
        List<Message> messages=service.messageDetail(messageId);

        request.setAttribute("messages",messages);
        request.getServletContext().getRequestDispatcher("/admin/messageDetail.jsp").forward(request, response);
    }
}
